package cn.wolfcode.luowowo.web.controller;

import cn.wolfcode.luowowo.domain.Destination;
import cn.wolfcode.luowowo.domain.Strategy;
import cn.wolfcode.luowowo.domain.StrategyCatalog;
import cn.wolfcode.luowowo.service.*;
import cn.wolfcode.luowowo.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("destinations")
public class DestinationController {
    @Autowired
    private IRegionService regionService;
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private ITravelsService travelsService;
    /**
     * 查询热门目的地
     * @return
     */
    @GetMapping("hotRegion")
    public Object hotRegion(){
        return JsonResult.success(regionService.queryHotRegion());
    }

    /**
     * 查询区域下的目的地
     * @return
     */
    @GetMapping("search")
    public Object search(String regionId){

        return JsonResult.success(destinationService.queryByReginIdForApi(regionId));
    }
    /**
     * 吐司
     * @return
     */
    @GetMapping("toasts")
    public Object toasts(String destId){
        return JsonResult.success(destinationService.getToasts(destId));
    }
    /**
     * 目的地
     * @return
     */
    @GetMapping("detail")
    public Object detail(String id){
        return JsonResult.success(destinationService.select(id));
    }
    /**
     * 目的地下的所有攻略分类
     * @return
     */
    @GetMapping("catalogs")
    public Object catalogs(String destId){
        List<StrategyCatalog> scList = strategyCatalogService.queryCatalogsByDestId(destId);
        return JsonResult.success(scList);
    }
    /**
     * 点击量前3的攻略文章
     * @return
     */
    @GetMapping("strategies/viewnumTop3")
    public Object strategiesViewnumTop3(String destId){
        return JsonResult.success(strategyService.getDest(destId));
    }

    /**
     * 点击量前3的游记
     * @param destId
     * @return
     */
    @GetMapping("travels/viewnumTop3")
    public Object travelsViewnumTop3(String destId){
        return JsonResult.success(travelsService.getDest(destId));
    }
}
